package com.appview;

import com.util.Config;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
/**
 * Created by Qi_Huang on 2015/11/2.
 * 此类用于获取不同类型的table
 */
public class TableModel{
    private static JTable jTable;
    private static DefaultTableModel tableModel;

    //不可创建对象
    private TableModel() {

    }


    //获取课表table
    public static JTable getCourseTable() {

        tableModel = new DefaultTableModel(Config.DAY_LIST, Config.CLASS_LIST.length) {
            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };

        for (int i = 0; i < Config.CLASS_LIST.length; i++) {
            tableModel.setValueAt(Config.CLASS_LIST[i], i, 0);
        }
        jTable = new JTable(tableModel);
        jTable.setRowHeight(81);
        TableColumn column = jTable.getColumnModel().getColumn(0);
        column.setPreferredWidth(40);
        column.setMaxWidth(40);
        column.setMinWidth(40);

        return jTable;
    }


}
